import torch
import net
import torchvision.transforms as transforms
from PIL import Image
import json

trans = transforms.Compose(
    [transforms.Resize((32, 32)),
     transforms.ToTensor(),
     transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
     ])

img = Image.open("NRBG.bmp")
img = trans(img)

jsonString = json.dumps([{'layer': 'normalized', 'value': img.tolist()}])
with open('ImagePreProcess.json', 'w') as f:
    f.write(jsonString)
print('Generate finished.')